package com.guaju.yueshangLife.widget;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.content.Context;
import android.view.View;


public class MyDialog extends Dialog {
    private View view;
    public MyDialog(Context context, View view) {
        super(context);
        this.view=view;
    }

    public MyDialog(Context context, View view, int themeResId) {
        super(context, themeResId);
        this.view=view;
    }

    @Override
    public void show() {
        if (!isShowing()&&null!=getContext()){
        super.show();
        }

    }

    public void animation(int mDuration) {

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(view, "scaleX", 0.1f, 0.5f, 1).setDuration(mDuration),
                ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 0.5f, 1).setDuration(mDuration)
        );
        animatorSet.start();
        animatorSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
               MyDialog.super.show();
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

    }
}
